/*
 *  MiceCode.h
 *  micecode
 *
 * Copyright (c) 2011, Anton Babushkin
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * MiceCode designed as memory and speed effective alternative to JSON, optimized
 * for modern object-oriented languages like Python or Java. It's more powerful
 * than Bencode or BSON, and more effective than JSON. Protocol ideology
 * influenced by JSON, Bencode, FAST. MiceCode have the following data types:
 * Integer, Float, Boolean, None, String, Bytes, List, Map, Decimal. Floats, Integers and
 * Decimals are stored in the smallest possible representation that doesn't worse
 * precision. Protocol supports integers up to 2^64 bytes, floats up to 64 bits and
 * string/bytes length up to 2^64. This realization limitations:
 * floats up to 64 bits only (double).
 *
 * Version: 1.0
 */

#import <Foundation/Foundation.h>

@interface MCBoolean : NSObject

@property(assign) bool booleanValue;

+ (MCBoolean *)falseValue;

+ (MCBoolean *)trueValue;

+ (MCBoolean *)booleanFromInt:(int)v;

- (NSString *)stringValue;

@end

NSObject *miceDecode(NSData *data);

NSObject *miceDecodeObject(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

long long int miceDecodeInteger(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSNumber *miceDecodeFloat(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSUInteger miceDecodeSize(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSString *miceDecodeString(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSData *miceDecodeBytes(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSArray *miceDecodeList(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSDictionary *miceDecodeMap(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSDecimalNumber *miceDecodeDecimal(unsigned char *bytes, NSUInteger len, NSUInteger *idx);

NSData *miceEncode(NSObject *obj);

void miceEncodeObject(NSMutableData *data, NSObject *obj);

void miceEncodeInteger(NSMutableData *data, long long int obj, char type);

void miceEncodeFloat(NSMutableData *data, NSNumber *obj);

void miceEncodeSize(NSMutableData *data, char type, NSUInteger size);

void miceEncodeString(NSMutableData *data, NSString *obj);

void miceEncodeBytes(NSMutableData *data, NSData *obj);

void miceEncodeList(NSMutableData *data, NSArray *obj);

void miceEncodeMap(NSMutableData *data, NSDictionary *obj);

void miceEncodeDecimal(NSMutableData *data, NSDecimalNumber *obj);
